package com.cy.pet.order.controller;

import com.cy.pet.common.pojo.Order;
import com.cy.pet.common.service.OrderService;
import com.cy.pet.common.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @description:
 * @author: LiuXingYu
 * @date: 2021/10/8 10:25
 */

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;
    /*http://localhost:8301/order/addOrder*/
    /*生成单个订单*/
    @PostMapping("/addOrder")
    public SysResult addOrder(String userName, Integer itemId, Integer num){
        System.out.println(userName);
        System.out.println(itemId);
        System.out.println(num);
        Boolean flag = orderService.addOrder(userName,itemId,num);
        return SysResult.success();
    }
    /*http://localhost:8301/order/getAllOrder*/
    /*获取所有订单信息*/
    @GetMapping("/getAllOrder")
    public SysResult getAllOrder(String userName){
        List<Order> orders = orderService.getAllOrder(userName);
        return SysResult.success(orders);
    }
}

